﻿using System.Runtime.InteropServices;

namespace VisionCloud.Service.Ms
{
    public class MeasureDrawHotMapService
    {
        /// <summary>
        /// 热力图绘图（Windows平台）
        /// </summary>
        /// <param name="image_path"></param>
        /// <param name="dsit_threshold"></param>
        /// <param name="visualize_levelness"></param>
        /// <returns></returns>
        [DllImport("UpdateInterface.dll", EntryPoint = "drawHotMap_R", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        private static extern bool MeasureDrawHotMap_R_Windows(string image_path, float dsit_threshold, int visualize_levelness);

        /// <summary>
        /// 热力图绘图（Linux平台）
        /// </summary>
        /// <param name="image_path"></param>
        /// <param name="dsit_threshold"></param>
        /// <param name="visualize_levelness"></param>
        /// <returns></returns>
        [DllImport("UpdateInterface", EntryPoint = "drawHotMap_R", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        private static extern bool MeasureDrawHotMap_R_Linux(string image_path, float dsit_threshold, int visualize_levelness);

        /// <summary>
        /// 热力图绘图
        /// </summary>
        /// <param name="image_path">图片存放目录</param>
        /// <param name="dsit_threshold">打磨量</param>
        /// <param name="visualize_levelness">精度</param>
        /// <returns></returns>
        public static bool MeasureDrawHotMap_R(string image_path, float dsit_threshold, int visualize_levelness)
        {
            var isWindowsPlatform = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
            if (isWindowsPlatform)
                return MeasureDrawHotMap_R_Windows(image_path, dsit_threshold, visualize_levelness);

            return MeasureDrawHotMap_R_Linux(image_path, dsit_threshold, visualize_levelness);
        }

        /// <summary>
        /// 靠尺图绘图（Windows平台）
        /// </summary>
        /// <param name="image_path"></param>
        /// <param name="is_flatness"></param>
        /// <param name="is_vertical"></param>
        /// <param name="has_flatness"></param>
        /// <param name="has_vertical"></param>
        /// <returns></returns>
        [DllImport("UpdateInterface.dll", EntryPoint = "drawRulers_R", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        private static extern bool MeasureDrawRulers_R_Windows(string image_path, bool is_flatness, bool is_vertical, ref bool has_flatness, ref bool has_vertical);

        /// <summary>
        /// 靠尺图绘图（Linux）
        /// </summary>
        /// <param name="image_path"></param>
        /// <param name="is_flatness"></param>
        /// <param name="is_vertical"></param>
        /// <param name="has_flatness"></param>
        /// <param name="has_vertical"></param>
        /// <returns></returns>
        [DllImport("UpdateInterface", EntryPoint = "drawRulers_R", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        private static extern bool MeasureDrawRulers_R_Linux(string image_path, bool is_flatness, bool is_vertical, ref bool has_flatness, ref bool has_vertical);

        /// <summary>
        /// 靠尺图绘图
        /// </summary>
        /// <param name="image_path">图片存放目录</param>
        /// <param name="is_flatness"></param>
        /// <param name="is_vertical"></param>
        /// <param name="has_flatness"></param>
        /// <param name="has_vertical"></param>
        /// <returns></returns>
        public static bool MeasureDrawRulers_R(string image_path, bool is_flatness, bool is_vertical, ref bool has_flatness, ref bool has_vertical)
        {
            var isWindowsPlatform = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
            if (isWindowsPlatform)
                return MeasureDrawRulers_R_Windows(image_path, is_flatness, is_vertical, ref has_flatness, ref has_vertical);

            return MeasureDrawRulers_R_Linux(image_path, is_flatness, is_vertical, ref has_flatness, ref has_vertical);
        }
    }
}